import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param param string字符串 
     * @return string字符串
     */
    public static String compressString (String param) {
        // write code here
        StringBuilder stringBuilder = new StringBuilder();
        char[] s = param.toCharArray();
        int left = 0,right = 0,n = param.length();
        while (left < n){
            while(right + 1 < n && s[right + 1] == s[right]) right++;
            int len = right - left + 1;
            stringBuilder.append(s[left]);
            if(len > 1) stringBuilder.append(len);
            left = right + 1;
            right = left;
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        String aa = "aabcccccaaa";
        System.out.println(compressString(aa));
    }
}